package com.okwanshiwu.util;

import com.alibaba.fastjson.JSON;

import java.util.HashMap;
import java.util.Map;

public final class TipCode {
	private int code = -1;
	private String msg = "系统内部错误";
	
	private Map<String,Object> result = new HashMap<String,Object>(0);
	
	public TipCode(){}
	public TipCode(int code,String msg){
		this.code = code;
		this.msg = msg;
	}
	public int getCode() {
		return code;
	}
	public void setCode(int code) {
		this.code = code;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	public Map<String,Object> toMap() {
		this.result.put("code", code);
		this.result.put("msg", msg);
		return this.result;
	}
	
	public void putData(String k,Object v){
		this.result.put(k, v);
	}
	
	public Map<String,Object> setCodeAndMsg(int code,String msg){
		this.code = code;
		this.msg = msg;
		return this.result;
	}

	public String toJson(){
		return JSON.toJSONString(toMap());
	}
}
